<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.prime.com.tr/ui">
    
 
  		
  	<div id="filtros" >
			<div id="divInput">
				
			<ui:include src="/caixa/elements/extrato/filtro-datas.xhtml"></ui:include>
				
				<div>
					<h:outputLabel value="Cliente: " for="cliente"/>
					<p:autoComplete id="cliente"
						value="#{extratoMB.cliente}"
						completeMethod="#{extratoMB.listarClientes}"
						var="cliente"
						itemLabel="#{cliente.nome}"
						itemValue="#{cliente}"
						converter="clienteConverter"
						validator="clienteValidator"
						size="30"
						onkeypress="nofificationBar.hide()"
						/>
				</div>
	  			
				<div style="padding-top: 12px;">
					<p:commandButton value="Pesquisar" 
						id="btnPesquisarExtratoCliente"
						action="#{extratoMB.pesquisarExtratoCliente}" 
						update="panelGridExtratoCliente panelGridButtonsCliente msg"
						oncomplete="showHideNotificationBar()"
						/>										
				</div>	  			
	  						
			</div> 
			<div style="clear: both;"></div> 			
  		</div>
  		
  		<div class="divContent" >
			<h:panelGrid id="panelGridExtratoCliente" style="width: 100%">  		  		
	  			<p:dataTable 
	  				value="#{extratoMB.extratoDTO.itensExtrato}"
	  				var="itenExtrato"
	  				id="tableItensExtratoCliente"
	  				rows="15"
	  				paginator="true"
	  				paginatorPosition="bottom"
	  				rendered="#{not empty extratoMB.extratoDTO.itensExtrato}"  				
	  				>  			
						<p:column>
							<f:facet name="header">
								<h:outputText value="Data" /> 
							</f:facet>
							<h:outputText value="#{itenExtrato.dataLancamento}" >
								<f:convertDateTime pattern="dd/MM/yyyy"/>
							</h:outputText>
							
						</p:column>  			
	  			
						<p:column>
							<f:facet name="header">
								<h:outputText value="Natureza" /> 
							</f:facet>
							<h:outputText value="#{itenExtrato.natureza}" />
						</p:column>
	
						<p:column>
							<f:facet name="header">
								<h:outputText value="Valor" /> 
							</f:facet>
							<h:outputText value="#{itenExtrato.valor}" >
								<f:convertNumber pattern="R$ ###,###,###,##0.00" locale="pt_BR"/>
							</h:outputText>
						</p:column>
						
						<f:facet name="footer">
							Saldo Atual =
							<h:outputText value="#{extratoMB.extratoDTO.saldoAtual}" styleClass="#{extratoMB.extratoDTO.saldoAtual lt 0 ? 'negativo' : 'positivo'}">
								<f:convertNumber pattern="R$ ###,###,###,##0.00" locale="pt_BR"/>
							</h:outputText>
						</f:facet>  			
	  			</p:dataTable>
  			</h:panelGrid>
  		</div>
  		
		<div class="divContent" id="commandButtons">			
			<h:panelGrid id="panelGridButtonsCliente" style="width: 100%">
				<p:commandButton 
					ajax="false" 
					value="Download Extrato"
					immediate="true"
					rendered="#{not empty extratoMB.extratoDTO.itensExtrato}"
					>
					<p:fileDownload value="#{extratoMB.fileExtrado}" />
				</p:commandButton>
			</h:panelGrid>
		</div>  		
	    
</ui:composition>
